package com.glsc.ngateway.common.base.domain.mysql.gateway.platform;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name = "t_interface_access_history_table")
public class TInterfaceAccessHistoryTable implements Serializable {
//t_am_web_log，把调用方IP、接口URL、账号（虽然现在没有，后面会有）、用时、yyyymmdd时间都加上。
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
    // 接口参数名称
    @Column(name = "params")
    private String params;
    // 接口名称
    @Column(name = "interface_name")
    private String interfaceName;
    // 接口调用时间
    @Column(name = "access_time")
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime accessTime;

    @Column(name = "ip")
    private String ip;
    @Column(name = "url")
    private String url;
    @Column(name = "account")
    private String account;
    /**
     * 响应花费时间，毫秒
     */
    @Column(name = "cost_time")
    private Long costTime;

}
